/**
 * Copyright &copy; 2013-2015 山东易科德软件有限公司   All rights reserved.
 */
package cn.net.ecode.modules.msg.entity;

import java.util.Date;

import javax.validation.constraints.NotNull;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import cn.net.ecode.common.persistence.DataEntity;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 消息管理Entity
 * @author ThinkGem
 * @version 2015-5-30
 */
@DataTransferObject
public class MessageRecord extends DataEntity<MessageRecord> {
	
	private static final long serialVersionUID = 1L;
	
	@RemoteProperty
	private Message message;		// 所属消息
	private String receiver;		// 接受者
	private String receiverName;	// 接受者姓名
	private Date receiveDate;		// 送达时间
	private Date readDate;			// 阅读时间
	
	public MessageRecord() {
		super();
	}

	public MessageRecord(Message message) {
		super();
		this.message = message;
	}

	public MessageRecord(String id){
		super();
		this.id = id;
	}

	@NotNull(message = "消息信息不能为空")
	public Message getMessage() {
		if (message == null){
			message = new Message();
		}
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}
	
	@NotBlank(message="接受者长度不能为空")
	@Length(min=0, max=64, message="接受者长度不能超过 64 个字符")
	public String getReceiver() {
		return receiver;
	}

	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}
	
	@Length(min=0, max=100, message="接受者姓名长度不能超过 100 个字符")
	public String getReceiverName() {
		return receiverName;
	}

	public void setReceiverName(String receiverName) {
		this.receiverName = receiverName;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getReceiveDate() {
		return receiveDate;
	}

	public void setReceiveDate(Date receiveDate) {
		this.receiveDate = receiveDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getReadDate() {
		return readDate;
	}

	public void setReadDate(Date readDate) {
		this.readDate = readDate;
	}
	
	@RemoteProperty 
	public String getIdKey()  {
		return id;
	}
	
	/**
	 * 消息记录状态标记（0未送达 1未读 2已读）
	 */
	public static final String STATUS_UNDELIVERED  = "0";
	public static final String STATUS_UNREAD = "1";
	public static final String STATUS_READ = "2";
	
}